﻿using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.Threading;
using FutureApp.Sessions;
using FutureApp.Web.Models.Component;
using System.Web.Mvc;

namespace FutureApp.Web.Controllers
{
    /// <summary>
    /// 组件
    /// </summary>
    public class ComponentController : FutureAppControllerBase
    {
        public ISessionAppService SessionAppService { get; set; }
        public IMultiTenancyConfig MultiTenancyConfig { get; set; }
        public ILanguageManager LanguageManager { get; set; }

        [ChildActionOnly]
        public PartialViewResult LanguageSelection()
        {
            var model = new LanguageSelectionViewModel
            {
                CurrentLanguage = this.LanguageManager.CurrentLanguage,
                Languages = this.LanguageManager.GetLanguages()
            };
            return this.PartialView("_LanguageSelection", model);
        }

        [ChildActionOnly]
        public PartialViewResult UserMenu()
        {
            var model = new UserInfoViewModel
            {
                LoginInformations = AsyncHelper.RunSync(() => this.SessionAppService.GetCurrentLoginInformations()),
                IsMultiTenancyEnabled = this.MultiTenancyConfig.IsEnabled,
            };
            return this.PartialView("_UserMenu", model);
        }

        [ChildActionOnly]
        public PartialViewResult TenancyMenu()
        {
            var model = new UserInfoViewModel
            {
                LoginInformations = AsyncHelper.RunSync(() => this.SessionAppService.GetCurrentLoginInformations()),
                IsMultiTenancyEnabled = this.MultiTenancyConfig.IsEnabled,
            };
            return this.PartialView("_TenancyMenu", model);
        }
    }
}
